<template>
    <div style="width: 1200px;margin:0 auto;">
        <!-- 面包屑设置 -->
        <bread-crumb title="院校信息"></bread-crumb>
        <!-- 整体页面设置 -->
        <div class="introduction-head f-c-sb">
            <!-- 左边样式 ：轮播图部分-->
            <div class="introduction-head-left">
                <el-carousel style="height: 100%;">
                    <el-carousel-item v-for="item in topSchool" :key="item.id" style="height: 416px;">
                        <div class="el-image">
                            <img :src="'/api' + item.firstImage" alt=""
                                style="object-fit: cover; height: 416px;width: 660px;">
                            <div class="banner-text">
                                {{ item.schoolName }}
                            </div>
                        </div>
                    </el-carousel-item>
                </el-carousel>
            </div>
            <!-- 右边样式：列表部分 -->
            <div class="introduction-head-right">
                <div class="head-right-item f-st" v-for="item in topSchool" :key="item.id" @click="gotoschool(item.id)">
                    <div>
                        <div class="el-image" style="width: 247px; height: 140px;">
                            <img :src="'/api' + item.firstImage" class="el-image__inner" style="object-fit: cover;">
                        </div>
                    </div>
                    <div class="head-right-item-right f-c">
                        <div style="height: 100%;">
                            <div class="school-name">
                                {{ item.schoolName }}
                            </div>
                            <div class="school-item-line"></div>
                            <div class="school-synopsis">
                                {{ item.synopsis }}
                            </div>
                        </div>
                    </div>
                </div>
            </div>

        </div>
        <!-- 校园列表 -->
        <div>
            <div style="padding:23px 0px;margin:33px 0px 0px;">
                <div class="lable-item f-c-st">
                    <div class="lable-item-text">校园列表</div>
                    <div class="f-c-c">
                        <img src="../assets/ggdfx.png" alt="">
                    </div>
                </div>
            </div>
            <el-row>
                <el-col :span="6" v-for="item in allSchool" :key="item.id" @click="gotoschool(item.id)">
                    <div class="school-item">
                        <div>
                            <div class="el-image" style="width: 285px; height: 195px;">
                                <img :src="'/api' + item.firstImage" class="el-image__inner" style="object-fit: cover;">
                            </div>
                        </div>
                        <div class="f-c-c">
                            <div class="school-name">{{ item.schoolName }}</div>
                            <div class="f-c-c school-img">
                                <img src="../assets/images/title-right.png" alt="">
                            </div>
                        </div>
                        <div class="f-c-c" style="height: 27px;">
                            <div class="school-label" v-for="(label, index) in item.label" :key="index">
                                {{ label }}
                            </div>
                        </div>
                        <div class="margin border-bottom">
                            <span class="name"> 学校性质 </span>
                            <span class="content"> {{ item.schoolNature }} </span>
                        </div>
                        <div class="margin border-bottom">
                            <span class="name"> 学校电话 </span>
                            <span class="content"> {{ item.schoolPhone }} </span>
                        </div>
                        <div class="margin">
                            <span class="name"> 学校官网 </span>
                            <span class="content" style="color: rgb(61, 108, 186); cursor: pointer;">
                                {{ item.officialAddress }}
                            </span>
                        </div>
                    </div>
                </el-col>
            </el-row>
        </div>
    </div>
</template>

<script>
import { getAllSchool } from '../api/index'
import { getTopSchool } from '../api/School'
import breadCrumb from '../components/bread-crumb.vue'
export default {
  components: { breadCrumb },
    name: 'School',
    data() {
        return {
            // 校园列表数据
            topSchool: [],
            // 全部学校数据
            allSchool: [],
        }
    },
    methods: {
        // 跳转到学校信息页面
        gotoschool(id) {
            this.$router.push({ path: '/Introduction', query: { schoolId: id } })
        }
    },
    mounted() {
        // 获取轮播图学校信息
        getTopSchool().then(res => {
            this.topSchool = res.data
        }),
        // 获取全部学校信息
        getAllSchool().then(res => {
            this.allSchool = res.data
            this.allSchool.forEach((item, index) => {
                if (item.label) {
                    this.allSchool[index].label = item.label.split(',')
                }
            });
        })
    },
    updated() {
        this.$toTop()
    }
}
</script>

<style lang="less" scoped>
// 主体部分
.introduction-head {
    margin-top: 14px;

    // 左边布局
    .introduction-head-left {
        width: 660px;
        height: 416px;

        .el-image {
            position: relative;
            overflow: hidden;

            .banner-text {
                position: absolute;
                bottom: 0;
                width: 100%;
                height: 70px;
                background: #000000;
                opacity: 0.45;
                font-size: 21px;
                font-family: NotoSansHans-Bold;
                font-weight: bold;
                color: #ffffff;
                line-height: 70px;
                text-align: center;
                text-overflow: ellipsis;
                overflow: hidden;
                white-space: nowrap;
            }
        }
    }

    // 右边布局

    .introduction-head-right::-webkit-scrollbar {
        width: 0;
    }

    .introduction-head-right {
        padding-top: 1px;
        width: 530px;
        height: 416px;
        overflow: auto;

        .head-right-item {
            width: 516px;
            height: 141px;
            margin: 0 auto 10px auto;
            background-color: #ffffff;
            box-shadow: 0 2px 2px 2px rgba(115, 124, 139, 0.15);
            border-radius: 6px;

            .head-right-item-right {
                margin-left: 20px;

                .school-name {
                    font-size: 16px;
                    font-family: NotoSansHans-Regular;
                    font-weight: bold;
                    line-height: 50px;
                }

                .school-item-line {
                    width: 240px;
                    height: 1px;
                    background: #eeeeee;
                    margin: 10px 0;
                }

                .school-synopsis {
                    font-size: 14px;
                    font-family: NotoSansHans-Regular;
                    font-weight: 400;
                    color: #757575;
                    line-height: 20px;
                    text-overflow: ellipsis;
                    display: -webkit-box;
                    -webkit-box-orient: vertical;
                    -webkit-line-clamp: 2;
                    overflow: hidden;
                }
            }
        }
    }

}

.lable-item {
    width: 310px;

    .lable-item-text {
        font-family: NotoSansHans-Light;
        font-size: 22px;
        font-weight: normal;
        font-stretch: normal;
        line-height: 40px;
        letter-spacing: 0px;
        color: #000000;
        margin-right: 19px;
    }
}

.school-item {
    margin: 20px auto 0 auto;
    width: 285px;
    cursor: pointer;
    background-color: #ffffff;
    border-radius: 6px;
    padding-bottom: 10px;
    box-shadow: 0 2px 2px 3px rgba(115, 124, 139, 0.15);

    .school-name {
        font-family: NotoSansHans-Bold;
        font-size: 18px;
        font-weight: normal;
        font-stretch: normal;
        line-height: 40px;
        letter-spacing: 0px;
        color: #000000;
    }

    .school-img>img {
        width: 15px;
        margin-left: 9px;
    }

    .school-label {
        padding: 0 10px;
        background-color: #ffffff;
        border-radius: 6px;
        border: solid 1px #ba0825;
        opacity: 0.3;
        font-family: NotoSansHans-Regular;
        font-size: 12px;
        font-weight: normal;
        font-stretch: normal;
        line-height: 25px;
        letter-spacing: 0px;
        color: #ba0825;
        margin: 0 5px;
    }

    .border-bottom {
        border-bottom: 1px dashed #eaeaea;
    }

    .margin {
        margin: 0 11px;
    }

    .name {
        font-family: NotoSansHans-Bold;
        font-size: 14px;
        font-weight: normal;
        font-stretch: normal;
        line-height: 40px;
        letter-spacing: 0px;
        color: #000000;
        margin-right: 20px;
    }

    .content {
        font-family: NotoSansHans-Regular;
        font-size: 14px;
        font-weight: normal;
        font-stretch: normal;
        line-height: 40px;
        letter-spacing: 0px;
        color: #757575;
    }
}
</style>